-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve E2E Test Fixtures to be less flaky #2208
base: main
Are you sure you want to change the base?
Conversation
5cb7349
to
1d8a574
Compare
@andyleejordan @SeeminglyScience Did a lot of cleanup here, DAP tests run much faster and I should have cleaned up the race conditions, they've been completely reliable for me so far. The tests should also read fairly cleaner now as well. |
7f0083c
to
7ecdd5a
Compare
@JustinGrote running this through the internal pipeline right now! |
Sooo actually per 20fa478 we cannot currently run the tests on OneBranch since it's stuck with PowerShell 7.3...so this will have to wait until January 😵 |
7ecdd5a
to
b1bafa3
Compare
Hi @JustinGrote, we can finally run the tests again in ADO. Would you want to get this PR updated? Note that I had to skip the |
b1bafa3
to
b5c00a3
Compare
@andyleejordan rebased and passed locally for me. Lets see if ADO likes it. |
Looks like it works. I can do the logging fixups as a separate item especially now that the other logging stuff was implemented. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR improves the stability and clarity of the E2E test fixtures by reworking the PSES process host to use task- and interface-based patterns and by replacing the legacy LoggingStream with DebugOutputStream for logging LSP communication.
- Converted the StdioLanguageServerProcessHost and related test fixtures to use updated process management with task completion sources.
- Replaced LoggingStream with DebugOutputStream to log stream activity only when a debugger is attached.
- Updated references in tests and LSP fixtures to use the new host implementation.
Reviewed Changes
File | Description |
---|---|
test/PowerShellEditorServices.Test.E2E/Hosts/StdioLanguageServerProcessHost.cs | Refactored host start/stop logic to use task-based state tracking. |
test/PowerShellEditorServices.Test.E2E/Hosts/PsesStdioLanguageServerProcessHost.cs | Updated host constructor and environment variable references for improved test stability. |
test/PowerShellEditorServices.Test.E2E/Hosts/DebugOutputStream.cs | Introduced DebugOutputStream to log read/write operations when debugging tests. |
test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs | Updated tests to use the new host and logging methods; removed dependency on LoggingStream. |
test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs, LSPTestsFixtures.cs, IDebugAdapterClientExtensions.cs | Updated usage and references from the legacy process host to the new one. |
Various Process files | Removed legacy PsesStdioProcess and related files to consolidate host management. |
src/PowerShellEditorServices/Server/PsesDebugServer.cs | Minor formatting adjustment in the debug server response initialization. |
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs
Show resolved
Hide resolved
e12f94b
to
5642221
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I like this a lot, just some questions. Also as far as ADO goes at this point we just have to YOLO it. I can't easily test a PR against the pipeline that would actually block us from releasing if it broke. 🤷 (Long story, really annoying.)
test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs
Show resolved
Hide resolved
|
||
<ItemGroup> | ||
<!-- Used for Update-Help for some test fixtures --> | ||
<Content Include="..\PowerShellEditorServices.Test.Shared\PSHelp\**\*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this fix all the tests that depend on help, and could we remove the build step where we Update-Help
for the tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only if the tests use Microsoft.PowerShell.Utility cmdlets for their reference. This is only required for Windows PowerShell since it doesn't ship this help in-box, all pwsh flavors do ship help in-box and so we don't have to do this. Assuming we find/adjust all help-based tests to use Microsoft.PowerShell.Utility, then yes this should fix them in AzDO CI
@@ -1177,7 +1181,7 @@ await PsesLanguageClient | |||
[SkippableFact] | |||
public async Task CanSendGetCommentHelpRequestAsync() | |||
{ | |||
Skip.If(PsesStdioProcess.RunningInConstrainedLanguageMode && PsesStdioProcess.IsWindowsPowerShell, | |||
Skip.If(PsesStdioLanguageServerProcessHost.RunningInConstrainedLanguageMode && PsesStdioLanguageServerProcessHost.IsWindowsPowerShell, | |||
"Windows PowerShell doesn't trust PSScriptAnalyzer by default so it won't load."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, is this why people are having problems with the formatter "hanging" when they use Windows PowerShell? Food for thought...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be! Maybe I can get some LSP trace logs from them and stick in some telemetry to find out.
|
||
Assert.Contains("Extracts files from a specified archive", updatedCompletionItem.Documentation.String); | ||
Assert.Contains("Gets the current date and time.", updatedCompletionItem.Documentation.String); | ||
} | ||
|
||
[SkippableFact] | ||
public async Task CanSendHoverRequestAsync() | ||
{ | ||
Skip.If(IsLinux, "This depends on the help system, which is flaky on Linux."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need to skip this test now that the help is mocked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not? As you said lets YOLO it as a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think I separately fixed this test in the other branch so there might be a conflict, I'll rebase.
public async Task CanSendCompletionResolveWithModulePrefixRequestAsync() | ||
{ | ||
await PsesLanguageClient | ||
.SendRequest( | ||
"evaluate", | ||
new EvaluateRequestArguments | ||
{ | ||
Expression = "Import-Module Microsoft.PowerShell.Archive -Prefix Slow" | ||
Expression = $"Update-Help Microsoft.Powershell.Utility -SourcePath {s_binDir};Import-Module Microsoft.PowerShell.Utility -Prefix Test -Force" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh sweet, ok yeah, I think there's an Update-Help
in the build script too...
s_binDir, $"pses_test_logs_{Path.GetRandomFileName()}"); | ||
|
||
private const string s_logLevel = "Diagnostic"; | ||
private static readonly string[] s_featureFlags = { "PSReadLine" }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really pass this through in feature flags still? I didn't think we had anything in feature flags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just looked and I didn't see this feature flag actually referenced anywhere, so it can probably be removed but I think that should be the scope of another PR. You're probably seeing it here as a "change" because I moved the file to a new folder I belieeve.
5642221
to
4e68bf6
Compare
4e68bf6
to
52feb6c
Compare
e0e8c1e
to
a476e9f
Compare
It took longer than 1 minute in Github Actions!
@andyleejordan the PowerShellEditorServices/src/PowerShellEditorServices/Services/Symbols/Visitors/SymbolVisitor.cs Lines 275 to 276 in de0eea1
I will "fix" this test but please confirm if you're expecting something else. Also, completions allow for a |
Contengent assuming #2208 (comment) is OK from @andyleejordan
Contengent assuming #2208 (comment) is OK from @andyleejordan
69ef1bd
to
2d7d3e2
Compare
@andyleejordan I came up with a better way to do the "offline" help update in eaeefa1 and centralized it in the build script again. |
22993ea
to
34347ba
Compare
34347ba
to
b22510a
Compare
Oops. I don't think I'm expecting something else. And if I remember correctly on the sortText, VS Code completely ignored it and applies their own sorting. |
3eb0adb
to
50a806f
Compare
50a806f
to
2a65e3d
Compare
@andyleejordan this should be ready for re-review and an internal pipeline test. Changes summary:
|
LoggingStream
withDebugOutputStream
to log LSP communication to debug console when debugging tests- [ ] Wire up LSP Client logging to XUnitITestOutputHelper
- [ ] Wire up PSES Initial File Logging to debug console